<?php

// Function for decode the url of RSS sended by root lsl script
function decode_url($url){
	$chars = array("&","?","=","#","$");
	$chars_enc = array("$1","$2","$3","$4","$5");

	return str_replace($chars_enc, $chars, $url);
}

// Covert the HTML encoded char and remove html tags
function convert_enc_chars($string){
	// Caratteri da convertire
	$html2conv = array("&agrave;","&egrave;","&igrave;","&ograve;","&ugrave;","&rsquo;","&#039;","&eacute;","&amp;","&quot;","&euro;","&#8217;","&#8230;","&ldquo;","&rdquo;","egrave","&nbsp;","è","é","ù","à");
	$html_converted = array("a'","e'","i'","o'","u'","'","'","e'","&","\"","euro","\'","...","\"","\"","e'"," ","e'","e'","u'","a'");

	$string = html_entity_decode(strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS))));
	preg_match_all('~\&\#([0-9]{2,4});~',$string,$matches,PREG_SET_ORDER );

	foreach($matches as $match )
		        $string = str_replace($match[ 0],chr($match [1]),$string );

	$string = str_replace($html2conv, $html_converted, $string);

	return html_entity_decode($string , ENT_QUOTES);
}


?>